package cn.eonshine.cuba.inf.modular.biz.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.eonshine.cuba.inf.modular.biz.entity.CustomerInventoryData;
import cn.eonshine.cuba.inf.modular.biz.mapper.CustomerInventoryDataMapper;
import cn.eonshine.cuba.inf.modular.biz.service.ICustomerInventoryDataService;
import cn.eonshine.cuba.inf.modular.common.service.AbstractCommonService;

@Service
@Transactional
public class CustomerInventoryDataServiceImpl extends AbstractCommonService<CustomerInventoryDataMapper, CustomerInventoryData> implements ICustomerInventoryDataService {

	@Override
	public int transportDataHandle(CustomerInventoryData obj, int count) throws Exception {
		QueryWrapper<CustomerInventoryData> entity = new QueryWrapper<CustomerInventoryData>();
		entity.lambda().eq(CustomerInventoryData::getDataInputDatetime, obj.getDataInputDatetime());
		entity.lambda().eq(CustomerInventoryData::getCustomerId, obj.getCustomerId());
		entity.lambda().eq(CustomerInventoryData::getOilId, obj.getOilId());
		entity.lambda().eq(CustomerInventoryData::getRptDate, obj.getRptDate());
		
		boolean isSuccess = false;
		if(this.isUpdate==0){
			isSuccess = remove(entity);
		}else {
			isSuccess = update(obj, entity);
		}
		if(isSuccess) {
			count ++;
		}
		return count;
	}

	@Override
	public void mappingHandle(CustomerInventoryData obj) throws Exception {
		
	}

	@Override
	public boolean isUseCutomerSelectSQL() {
		return false;
	}

}
